Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split codec from scheme #17922

Merged
merged 17 commits into from
Jan 25, 2016
Merged

Conversation

smarterclayton
Copy link
Contributor

Move all serialization (codec) responsibilities out of the scheme. Separate serialization
responsibilities of codec from versioning responsibilities of codec.
Enforce that all objects have a version (add __internal and
__unversioned to represent those). Remove runtime.EmbeddedObject in favor
of pure runtime.Object -> runtime.RawExtension.

Disable the automatic encoding of runtime.Object during conversion - instead, require well behaved clients to interpret []runtime.Object themselves. This removes the need for conversion to be aware of codecs (and of objects that the conversion may not have registered).

Dramatically reduce the signature for Codec. On Decode, pass a GVK tuple that
represents the desired decoding. Return from the decode the actual origin type
that the user presented (will allow resthandler to do checking orthogonal to
behavior in codec). Serializer and Codec look the same - the Codec type is
for cases where conversion is in play, the serializer is where only raw wire
format is considered. Decode now returns enough info to make the right
decisions at both levels

Begins addressing #7111 and required to support protobuf #17854 (cannot
assume only one serialization type and 1 codec per version)

@k8s-bot
Copy link

k8s-bot commented Nov 29, 2015

GCE e2e build/test failed for commit 0be0992.

@k8s-github-robot
Copy link

Labelling this PR as size/XXL

@k8s-github-robot k8s-github-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 29, 2015
@deads2k
Copy link
Contributor

deads2k commented Nov 30, 2015

Any chance of breaking the codec method signature changes in a separate pull?

)

type serializerType struct {
AcceptContentTypes []string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this extend any interfaces? Seems like I'd want this to actually be an interface.

Also, public fields on a private struct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not for end users, merely to enable local code to extend it (for
now).

On Mon, Nov 30, 2015 at 7:49 AM, David Eads notifications@github.com
wrote:

In pkg/api/latest/codec.go
#17922 (comment)
:

  • "k8s.io/kubernetes/pkg/conversion"
  • "k8s.io/kubernetes/pkg/runtime"
  • "k8s.io/kubernetes/pkg/runtime/serializer/json"
  • "k8s.io/kubernetes/pkg/runtime/serializer/recognizer"
    +)

+var (

  • Codecs CodecFactory
  • UniversalDeserializer runtime.Decoder
  • jsonSerializer = json.NewSerializer(conversion.DefaultMetaFactory, api.Scheme, runtime.ObjectTyperToTyper(api.Scheme))
  • yamlSerializer = json.NewYAMLSerializer(conversion.DefaultMetaFactory, api.Scheme, runtime.ObjectTyperToTyper(api.Scheme))
    +)

+type serializerType struct {

  • AcceptContentTypes []string

Does this extend any interfaces? Seems like I'd want this to actually be
an interface.

Also, public fields on a private struct?


Reply to this email directly or view it on GitHub
https://github.com/kubernetes/kubernetes/pull/17922/files#r46138851.

@smarterclayton
Copy link
Contributor Author

It's far too invasive - I want to get a fully working system back before I
do that. However, go ahead and make your changes, assuming that I will
pick up purely mechanical string -> GVK changes. Identify any places where
you think the assumptions are changing.

On Mon, Nov 30, 2015 at 7:48 AM, David Eads notifications@github.com
wrote:

Any chance of breaking the codec method signature changes in a separate
pull?


Reply to this email directly or view it on GitHub
#17922 (comment)
.

@lavalamp
Copy link
Member

I have a bunch of stuff to catch up on, but I will try to look at this asap

"k8s.io/kubernetes/pkg/runtime/serializer/recognizer"
)

var (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recently, every time I've written code with global variables like this, I've later regretted it and replaced with some containing object. It makes testing easier, construction more well defined, etc. Up to you though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I agree as well - I need to break the code that depends on global
codecs today, and identify where codec is an injection vs global. There
are a few places where universal decoder is all that is all that is needed,
but injection is still important.

On Dec 1, 2015, at 7:07 PM, Daniel Smith notifications@github.com wrote:

In pkg/api/latest/codec.go
#17922 (comment):

+package latest
+
+import (

  • "fmt"
  • "io"
  • "reflect"
    +
  • "k8s.io/kubernetes/pkg/api"
  • "k8s.io/kubernetes/pkg/api/unversioned"
  • "k8s.io/kubernetes/pkg/conversion"
  • "k8s.io/kubernetes/pkg/runtime"
  • "k8s.io/kubernetes/pkg/runtime/serializer/json"
  • "k8s.io/kubernetes/pkg/runtime/serializer/recognizer"
    +)
    +
    +var (

Recently, every time I've written code with global variables like this,
I've later regretted it and replaced with some containing object. It makes
testing easier, construction more well defined, etc. Up to you though.


Reply to this email directly or view it on GitHub
https://github.com/kubernetes/kubernetes/pull/17922/files#r46359926.

@lavalamp
Copy link
Member

lavalamp commented Dec 2, 2015

I'm sure I missed things, hopefully not big things.

The nuance of Codec and Serializer was not at all obvious to me, but I can't think of better names off the top of my head.

Is Scheme still doing any useful work?

I think the stuff in the latest package needs to be reflected in the testapi package, or extracted to some common place (I think that sort of thing was the intended purpose of Scheme?) for use by both.

@smarterclayton
Copy link
Contributor Author

Agree something needs to be done with latest and testapi. As I'm walking
the changes out to packages I'm noticing the spots to change, will make
sure those get highlighted.

On Dec 1, 2015, at 7:49 PM, Daniel Smith notifications@github.com wrote:

I'm sure I missed things, hopefully not big things.

The nuance of Codec and Serializer was not at all obvious to me, but I
can't think of better names off the top of my head.

Is Scheme still doing any useful work?

I think the stuff in the latest package needs to be reflected in the
testapi package, or extracted to some common place (I think that sort of
thing was the intended purpose of Scheme?) for use by both.


Reply to this email directly or view it on GitHub
#17922 (comment)
.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 6, 2015
@k8s-bot
Copy link

k8s-bot commented Jan 22, 2016

GCE e2e test build/test passed for commit 3262d8e.

@lavalamp
Copy link
Member

LGTM, let's merge-- we can make incremental changes after this is in.

@smarterclayton
Copy link
Contributor Author

Adding label

@smarterclayton smarterclayton added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 23, 2016
@k8s-github-robot
Copy link

@k8s-bot test this

Tests are more than 48 hours old. Re-running tests.

@k8s-bot
Copy link

k8s-bot commented Jan 24, 2016

GCE e2e test build/test passed for commit 3262d8e.

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Jan 25, 2016

GCE e2e test build/test passed for commit 3262d8e.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

k8s-github-robot pushed a commit that referenced this pull request Jan 25, 2016
@k8s-github-robot k8s-github-robot merged commit d3b869a into kubernetes:master Jan 25, 2016
@smarterclayton
Copy link
Contributor Author

@k8s-oncall this is the biggest change that landed this morning, haven't ruled out it might not cause some of the more esoteric (non core e2e) tests to flake. Please ping me immediately if you see squirrelly behavior this morning.

@smarterclayton
Copy link
Contributor Author

@smarterclayton
Copy link
Contributor Author

gce-autoscaling works locally for me with gcr.io/google_containers/heapster:v0.18.4 and the latest staged source (from https://console.cloud.google.com/storage/browser/kubernetes-jenkins/logs/kubernetes-e2e-gce-autoscaling/2541/?pli=1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/scalability Categorizes an issue or PR as relevant to SIG Scalability. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants